//
// Created by Castle-Moriarty on 2025/10/31.
//

#include <iostream>
using namespace std;

int main() {
    // 输入年 月 日，输出该天是这一年的第几天
    int months[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int year, month, day,sum = 0;
    cin >> year >> month >> day;
    for (int i = 1;i < month;i++) {
        sum += months[i];
    }
    sum += day;
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
        if (month > 2) {
            sum ++;
        }
    }
    cout << sum << endl;
    return 0;
}